<CFSETTING ENABLECFOUTPUTONLY="Yes"> 

<!--- 
	Required Parameters:
	tl  - lookup table location
	tn  - lookup tablename
	df  - comma-delimited fields to be displayed in the lookup
	rf  - field to be returned
	frm - formname
	fn  - fieldname
 --->
 
<CFIF NOT(ParameterExists(url.tl)) OR
			NOT(ParameterExists(url.tn)) OR
			NOT(ParameterExists(url.df)) OR
			NOT(ParameterExists(url.rf)) OR
			NOT(ParameterExists(url.frm)) OR
			NOT(ParameterExists(url.fn)) OR
			NOT(ParameterExists(url.desc))>
	<SCRIPT LANGUAGE="JavaScript">
		<!--
		alert('Cannot open a lookup with incomplete parameters.');
		window.close();
		-->
	</SCRIPT>
</CFIF>

<!--- get table location --->
<!--- custom tag: parameter: DBLEVEL; return value: DSN --->
<CFMODULE TEMPLATE="#client.common_path#cfm_leveldsn.cfm" DBLEVEL="#tl#">
<CFSET table_dsn = DSN>

<!--- Delete ambiguous column naming in select list (url.df) --->
<CFSET strURLDF = "">
<CFLOOP LIST="#url.df#" INDEX="x">
	<CFIF NOT ListContainsNoCase(strURLDF,x)>
		<CFIF strURLDF EQ "">
			<CFSET strURLDF = x>
		<CFELSE>
			<CFSET strURLDF = strURLDF & ',' & x>
		</CFIF>
	</CFIF>
</CFLOOP>
<!--- set default for eform --->
<CFSET eform.sender    = "#getFileFromPath(getBaseTemplatePath())#?tl=#url.tl#&tn=#url.tn#&df=#strURLDF#&rf=#url.rf#&frm=#url.frm#&fn=#url.fn#&desc=#url.desc#">
<CFSET eform.tablename = "#url.tn#">
<CFPARAM NAME="eform.locator" DEFAULT="">
<CFPARAM NAME="eform.field" 	DEFAULT="#url.rf#">
<CFPARAM NAME="eform.char"    DEFAULT="all">
<CFPARAM NAME="eform.addnew"  DEFAULT="N">
<CFPARAM NAME="form.startrow" DEFAULT=1>

<!--- first --->
<CFIF 
	isDefined("Form.First") OR
	isDefined("Form.Prior") OR
	isDefined("Form.Next") OR
	isDefined("Form.Last") OR
	isDefined("Form.Filter")>

	<CFSET eform.field 	 = Form.cmbSort>
	<CFSET eform.char  	 = Form.cmbFilter>
	<CFSET eform.locator = Form.edtValFilter>
</CFIF>	

<!--- selected filter value --->
<CFIF isDefined("Form.Sort") OR
			isDefined("Form.Filter")>
	<CFSET form.startrow = 1>
	<CFSET eform.field = Form.cmbSort>
</CFIF>	

<CFSETTING ENABLECFOUTPUTONLY="No">

<CFINCLUDE TEMPLATE="#client.common_path#_toggle.cfm">
<SCRIPT LANGUAGE="JavaScript">
	<!--
	function SetLookup(sRetVal, sRetDesc)	{
	<CFOUTPUT>
		var FormName  = "#url.frm#";
		var FieldName = "#url.fn#";
		eval("self.opener.document." + FormName + ".hid" + FieldName + ".value = sRetVal");
		eval("self.opener.document." + FormName + ".edt" + FieldName + ".value = sRetVal");
		eval("self.opener.document." + FormName + ".lk"  + FieldName + ".value = sRetDesc");
		window.close();
	</CFOUTPUT>
	}
	-->
</SCRIPT>

<HTML>
<HEAD>
	<TITLE>iBOS/e Lookup Dialog</TITLE>
	<CFOUTPUT>
	<LINK REL="StyleSheet" HREF="#client.wstheme_path##client.empcolor#.css" TYPE="text/css">
	</CFOUTPUT>
</HEAD>

<BODY TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0 BOTTOMMARGIN=0 BGCOLOR="#FFFFFF">

	<CFSETTING ENABLECFOUTPUTONLY="Yes">

	<!--- get records for the eform for browsing --->
	<CFQUERY NAME="GetLookup" DATASOURCE="#table_dsn#">
		SELECT #strURLDF#
		FROM #eform.tablename#
		<CFIF trim(eform.locator) NEQ "">
			WHERE (#eform.field# LIKE '%#eform.locator#%')
		<CFELSE>
			<CFIF eform.char EQ "all">
			<CFELSEIF eform.char EQ "">	
				WHERE (#eform.field# IS NULL)
			<CFELSE>	
				WHERE (#eform.field# LIKE '#eform.char#%')
			</CFIF>
		</CFIF>	
		ORDER BY #strURLDF#
	</CFQUERY>
	<CFSETTING ENABLECFOUTPUTONLY="No">
	
	<CFSET appname = url.desc>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="#appname#">

	<CFOUTPUT>	
	<FORM METHOD="post" ACTION="#eform.sender#" NAME="BrwLookup">
	</CFOUTPUT>	

	<CFINCLUDE TEMPLATE="_poptoolbar.cfm">

	<!--- to browse on records --->
	<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1 WIDTH="100%">
		<CFIF NOT GetLookup.RecordCount>
			<TR><TD>No records found in the current filter.</TD></TR>
		<CFELSE>
			<CFOUTPUT>
			<TR bgcolor="#client.color_tblhead#">
				<CFSET iBrowseCtr = 0>
				<CFLOOP INDEX="x" LIST="#strURLDF#" DELIMITERS=",">
					<TD class="boldwhite" HEIGHT=18>&nbsp;#x#</TD>
					<CFSET iBrowseCtr = iBrowseCtr + 1>
				</CFLOOP>
			</TR> 
			<TR BGCOLOR="#client.color_tblset1#">
				<TD HEIGHT="20">
					&nbsp;
					<A HREF="javascript:SetLookup('', '')">&lt;null value&gt;</A>
				</TD>
				<TD>Clear current value</TD>
			</TR>				
			</CFOUTPUT>

			<CFOUTPUT QUERY="GetLookup" StartRow="#form.startrow#" MaxRows="#OnEachPage#">
				<TR BGCOLOR="#IIf(CurrentRow Mod 2, "client.color_tblset2", "client.color_tblset1")#" VALIGN="top">
 	  			<TD NOWRAP HEIGHT=17>
						<CFSET sLkDesc = Evaluate("GetLookup." & ListLast(strURLDF))>
						<CFSET sLkDesc = Replace(sLkDesc, "'", "", "ALL")>
						&nbsp;
						<A HREF="javascript:SetLookup('#evaluate("GetLookup." & ListFirst(strURLDF))#', '#sLkDesc#')">
							#evaluate("GetLookup." & ListFirst(strURLDF))#</A>
					</TD>	
					<TD>
						#evaluate("GetLookup." & ListLast(strURLDF))#
					</TD>
			  </TR>
			</CFOUTPUT>
			
			<CFOUTPUT>
				<TR bgcolor="#client.color_tblfoot#">
					<TD class="white" HEIGHT=18 COLSPAN="#iBrowseCtr#">
						&nbsp;
						Records: <B>#form.startrow#-#EndRow#</B>
						&nbsp;of&nbsp;
						<B>#GetLookup.RecordCount#</B>
					</TD>
				</TR>
			</CFOUTPUT>
		</CFIF>
		</FORM>
	</TABLE>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
	
</BODY>
</HTML>
		

	